package com.moonlit.myspring;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * @Autowired自动装配的注解
 * 如果两个实现类同时实现一个接口，那么可以使用 @Qualifier("halberd")来选取你想要的实现
 */
public class GuanYu implements Hero{
    @Autowired
    @Qualifier("halberd")
    private Weapon weapon;

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }

    @Override
    public void perform() {
        System.out.println("GuanYu pick up his weapon");
        weapon.attack();
    }
}
